package com.server;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.Helper.CustomerHelper;
import com.Helper.FlightHelper;
import com.Helper.FlightInfo;
import com.Helper.ReservationHelper;
import com.Helper.ReservationInfo;
import com.Helper.SeatHelper;
import com.Helper.SeatInfo;

public class ModResServlet extends CustomerServlet
{
	private static final long serialVersionUID = 1L;
	String msg = null;

	@Override
	//@requires HttpServletRequest !=NULL,  HttpServletResponse !=NULL ;
	//@signals_only RuntimeException, IOException,ServletException;
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException
	{
		ConnectDB();
		String username = req.getParameter("username");
		String resID = req.getParameter("resID");
		boolean chicken = false;
		boolean beef = false;
		boolean vege = false;
		
		try 
		{
			ReservationHelper.Setup(connection, username);
			ReservationInfo resInfo = ReservationHelper.GetSelectedReservation(Integer.parseInt(resID));
			
			
			if (resInfo.meal.equals("Chicken"))
			{
				chicken = true;
			}
			else if (resInfo.meal.equals("Beef"))
			{
				beef = true;
			}
			else if (resInfo.meal.equals("Vegetarian"))
			{
				vege = true;
			}
			String flight1="'"+resInfo.flightID+"'";
			req.setAttribute("flight", flight1);
			req.setAttribute("resInfo", resInfo);
			req.setAttribute("flightID", resInfo.flightID);
			req.setAttribute("username", username);
			req.setAttribute("resID", resID);
			req.setAttribute("chicken", chicken);
			req.setAttribute("beef", beef);
			req.setAttribute("vege", vege);
			req.getRequestDispatcher("reservation/ModGeneral.jsp").forward(req, resp);
		} 
		catch (SQLException e) 
		{
			e.printStackTrace();
		}
		
		
	}
}

